package com.example.webtest.web.api;

import com.example.webtest.req.LoginReq;
import com.example.webtest.web.restcfg.R;
import com.example.webtest.web.restcfg.ResultCodeEnum;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestApi {



    @PostMapping("/user/login")
    public R<String> userLogin(@RequestParam String username,
                               @RequestParam String password){
        System.err.println(username);
        System.err.println(password);

        if (username.equals("admin") && password.equals("123456")){
            return R.ok();
        }else {
            return R.fail(ResultCodeEnum.ERROR);
        }
    }


    @PostMapping("/user/login2")
    public R<String> userLogin(@RequestBody LoginReq req){
        System.err.println(req);

        if (req.getUsername().equals("admin") && req.getPassword().equals("123456")){
            return R.ok();
        }else {
            return R.fail(ResultCodeEnum.ERROR);
        }
    }

}
